﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:my="clr-namespace:uTorrentSL"
             xmlns:cx="clr-namespace:uTorrentSL.Behaviors"
             xmlns:cv="clr-namespace:uTorrentSL.Converters"
            xmlns:dv="clr-namespace:DevEnverModal"
             xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
            x:Class="uTorrentSL.Views.TorrentsView"
            
             mc:Ignorable="d"
			 d:DesignHeight="300"
			 d:DesignWidth="300"
             >
    <UserControl.Resources>
        <cv:TimeSpanConvert x:Key="TimeC"/>
		<cv:NotConverter x:Key="Not"/>
        <cv:BooleanToVisibility x:Key="b2v"/>
    </UserControl.Resources>
	<UserControl.DataContext>
		<Binding Path="TorrentsViewModel" Source="{StaticResource Locator}"/>
	</UserControl.DataContext>
    <Grid>
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,50,0">
                <HyperlinkButton Style="{StaticResource LinkStyle}" MinHeight="0" MinWidth="0" Padding="0,0,5,0" FontSize="18" Content="+ file" Margin="0,0,0,0" >
            	<i:Interaction.Triggers>
            		<i:EventTrigger EventName="Click">
            			<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding UploadCommand}"/>
            		</i:EventTrigger>
            	</i:Interaction.Triggers>
            </HyperlinkButton>
            <HyperlinkButton Style="{StaticResource LinkStyle}" MinHeight="0" MinWidth="0" Padding="0,0,0,0" FontSize="18" Content="+ url">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding LaunchModalCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="AddTorrentUrl" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </HyperlinkButton>
        </StackPanel>
        <ListBox x:Name="lbTorrents" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Data.Torrents}" Grid.Row="1">
            
            <ListBox.ItemTemplate>
                <DataTemplate>
                	<Grid>
                    <Border Canvas.ZIndex="10" Background="Transparent">
                    	<i:Interaction.Triggers>
                                    <cx:DoubleClickTrigger>
                                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding TorrentsViewModel.SelectCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding SelectedItem, ElementName=lbTorrents}"/>
										<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding Main.SetControl, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="TorrentView"/>
                                    </cx:DoubleClickTrigger>
                                </i:Interaction.Triggers>
					
                    </Border>
                        <StackPanel Margin="0,0,0,0">
                            <TextBlock Text="{Binding Name}" UseLayoutRounding="True">
                                

                            </TextBlock>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Margin" Value="0,0,10,0"/>
                                    <Setter Property="Foreground" Value="Gray"/>
                                </Style>
                            </StackPanel.Resources>
                            <TextBlock Text="{Binding StatusMessage}" UseLayoutRounding="True"/>
                            <TextBlock Text="{Binding TimeEstimate, Converter={StaticResource TimeC}}" UseLayoutRounding="True"/>
                            <TextBlock Text="{Binding Label}" UseLayoutRounding="True"/>
                        </StackPanel>
                    </StackPanel>
					</Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
    </Grid>
    </Grid>
</UserControl>
